#include<iostream>
using namespace std;
const int N = 1e2 + 10;
int brr[N][N];
void insert(int x1, int y1, int x2, int y2, int c)
{
	brr[x1][y1] += c;
	brr[x1][y2 + 1] -= c;
	brr[x2 + 1][y1] -= c;
	brr[x2 + 1][y2 + 1] += c;
}

int main()
{
	int n, m, q;
	cin >> n >> m >> q;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			int c;
			cin >> c;
			insert(i, j, i, j, c);
		}
	}
	while (q--) {
		int a, b, c, d, e;
		cin >> a >> b >> c >> d >> e;
		insert(a, b, c, d, e);
	}
	for (int i = 1; i < n + 1; i++) {
		for (int j = 1; j < m + 1; j++) {
			brr[i][j] += brr[i - 1][j] + brr[i][j - 1] - brr[i - 1][j - 1];
		}
	}
	for (int i = 1; i < n + 1; i++) {
		for (int j = 1; j < m + 1; j++) {
			cout << brr[i][j] << " ";
		}
		cout << endl;
	}
	return 0;
}